import { defineAsyncComponent } from 'vue'
import type { App } from 'vue'
import * as svg from '@element-plus/icons-vue'

const SvgIcon = defineAsyncComponent(() => import('/@/components/svgIcon/index.vue'))
// 全局注册基础组件
const BaseDialog = defineAsyncComponent(() => import('/@/components/baseDialog/index.vue'))
const BaseForm = defineAsyncComponent(() => import('/@/components/baseForm/index.vue'))
const BaseFormItem = defineAsyncComponent(() => import('/@/components/baseFormItem/index.vue'))
const BaseTable = defineAsyncComponent(() => import('/@/components/baseTable/index.vue'))
const Pagination = defineAsyncComponent(() => import('/@/components/pagination/index.vue'))

export function registerSvg(app: App) {
	const icons = svg as any
	for (const i in icons) {
		app.component(`ele-${icons[i].name}`, icons[i])
	}
	app.component('SvgIcon', SvgIcon)
	app.component('BaseDialog', BaseDialog)
	app.component('BaseForm', BaseForm)
	app.component('BaseFormItem', BaseFormItem)
	app.component('BaseTable', BaseTable)
	app.component('Pagination', Pagination)
}